package me.keiwu.task.service;

import me.keiwu.pub.data.Response;
import me.keiwu.pub.data.ResponseV2;
import me.keiwu.task.domain.Challenge;
import me.keiwu.task.util.bean.Achievement;
import org.springframework.data.domain.Page;

import javax.annotation.Nullable;
import java.util.Date;
import java.util.List;

/**
 * Created by kei on 13/11/2017.
 */
public interface ChallengeService {

	Challenge getByChallengeId(Long challengeId);

	Achievement getAchievement(Long userId);

	/**
	 * 查找自己相关的进行中挑战
	 * 
	 * @param userId
	 * @param page
	 * @param size
	 * @return
	 */
	Page<Challenge> findUserStartingChallenges(Long userId, int page, int size);

	/**
	 * 查找所有用户相关的任务
	 * 
	 * @param userId
	 * @param page
	 * @param size
	 * @return
	 */
	Page<Challenge> findUserChallenges(Long userId, int page, int size);

	/**
	 * 分页查找全部已经结束的挑战
	 * 
	 * @param userId
	 * @param page
	 * @param size
	 * @return
	 */
	Page<Challenge> findUserEndChallenges(Long userId, int page, int size);

	/**
	 * 获取全部已经结束的挑战
	 * 
	 * @param userId
	 * @return
	 */
	List<Challenge> findAllUserEndChallenges(Long userId);

	/**
	 * 查找其他人正在进行的挑战，不包括初始化的
	 * 
	 * @param userId
	 * @param page
	 * @param size
	 * @return
	 */
	Page<Challenge> findOtherChallenges(Long userId, int page, int size);

	/**
	 * 查找所有挑战
	 * 
	 * @param state
	 * @param afterDate
	 * @param beforeDate
	 * @param page
	 * @param size
	 * @return
	 */
	Page<Challenge> findAllChallenges(@Nullable Integer state, @Nullable Date afterDate, @Nullable Date beforeDate,
			@Nullable String name, int page, int size);

	/**
	 * 查找所有进行中的挑战
	 * 
	 * @param page
	 * @param size
	 * @return
	 */
	Page<Challenge> findAllStartingChallenges(int page, int size);

	Challenge closeChallenge(Long challengeId);

	Challenge reopenChallenge(Long challengeId);

	Challenge createChallenge(Long userId, Long challenger, String name, Date startDate, Date endDate);

	Response replyChallenge(Long challengeId, Long invitee, int state);

	Response awardChallenge(Long userId, Long challengeId);

	Response awardAllChallenge(Long userId);

	Response triggerUpdateStep(long userId);

	Page<Challenge> findChallengesByName(String name, int page, int size);

	Integer countAllChallenges(Long userId);

	Integer countStartingChallenges(Long userId);

	boolean checkHasChallenge(Long userId, Long otherId);

	boolean checkCanChallenge(Long userId, Long otherId, Date startDate, Date endDate);

//	Response testAcceptChallenge(Long userId, Long invitee, Long challengeId);
//
//	Response testInviteChallenge(Long invitee, Long inviter, Long challengeId);
//
//	Response testSendGameResult(Long userId);

	Page<Challenge> findYesterdayChallenge(int page, int size);

	Challenge findChallengeById(Long challengeId);
}
